{
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "# Gaussian Regression"
      ],
      "metadata": {
        "nteract": {
          "transient": {
            "deleting": false
          }
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import numpy as np\n",
        "import matplotlib.pyplot as plt\n",
        "import pandas as pd\n",
        "\n",
        "import warnings\n",
        "warnings.filterwarnings(\"ignore\")\n",
        "\n",
        "import yfinance as yf\n",
        "yf.pdr_override()"
      ],
      "outputs": [],
      "execution_count": 1,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:24.907Z",
          "iopub.execute_input": "2022-05-28T21:33:24.913Z",
          "shell.execute_reply": "2022-05-28T21:33:24.874Z",
          "iopub.status.idle": "2022-05-28T21:33:24.920Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# input\n",
        "symbol = 'AMD'\n",
        "start = '2014-01-01'\n",
        "end = '2018-08-27'\n",
        "\n",
        "# Read data \n",
        "dataset = yf.download(symbol,start,end)\n",
        "\n",
        "# View Columns\n",
        "dataset.head()"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "[*********************100%***********************]  1 of 1 completed\n"
          ]
        },
        {
          "output_type": "execute_result",
          "execution_count": 2,
          "data": {
            "text/plain": "            Open  High   Low  Close  Adj Close    Volume\nDate                                                    \n2014-01-02  3.85  3.98  3.84   3.95       3.95  20548400\n2014-01-03  3.98  4.00  3.88   4.00       4.00  22887200\n2014-01-06  4.01  4.18  3.99   4.13       4.13  42398300\n2014-01-07  4.19  4.25  4.11   4.18       4.18  42932100\n2014-01-08  4.23  4.26  4.14   4.18       4.18  30678700",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2014-01-02</th>\n      <td>3.85</td>\n      <td>3.98</td>\n      <td>3.84</td>\n      <td>3.95</td>\n      <td>3.95</td>\n      <td>20548400</td>\n    </tr>\n    <tr>\n      <th>2014-01-03</th>\n      <td>3.98</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>22887200</td>\n    </tr>\n    <tr>\n      <th>2014-01-06</th>\n      <td>4.01</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.13</td>\n      <td>4.13</td>\n      <td>42398300</td>\n    </tr>\n    <tr>\n      <th>2014-01-07</th>\n      <td>4.19</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>42932100</td>\n    </tr>\n    <tr>\n      <th>2014-01-08</th>\n      <td>4.23</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>30678700</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 2,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:24.927Z",
          "iopub.execute_input": "2022-05-28T21:33:24.933Z",
          "iopub.status.idle": "2022-05-28T21:33:25.380Z",
          "shell.execute_reply": "2022-05-28T21:33:25.526Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "dataset['Increase_Decrease'] = np.where(dataset['Volume'].shift(-1) > dataset['Volume'],1,0)\n",
        "dataset['Buy_Sell_on_Open'] = np.where(dataset['Open'].shift(-1) > dataset['Open'],1,0)\n",
        "dataset['Buy_Sell'] = np.where(dataset['Adj Close'].shift(-1) > dataset['Adj Close'],1,0)\n",
        "dataset['Returns'] = dataset['Adj Close'].pct_change()\n",
        "dataset = dataset.dropna()"
      ],
      "outputs": [],
      "execution_count": 3,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:25.388Z",
          "iopub.execute_input": "2022-05-28T21:33:25.392Z",
          "iopub.status.idle": "2022-05-28T21:33:25.401Z",
          "shell.execute_reply": "2022-05-28T21:33:25.531Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "dataset.head()"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 4,
          "data": {
            "text/plain": "            Open  High   Low  Close  Adj Close    Volume  Increase_Decrease  \\\nDate                                                                          \n2014-01-03  3.98  4.00  3.88   4.00       4.00  22887200                  1   \n2014-01-06  4.01  4.18  3.99   4.13       4.13  42398300                  1   \n2014-01-07  4.19  4.25  4.11   4.18       4.18  42932100                  0   \n2014-01-08  4.23  4.26  4.14   4.18       4.18  30678700                  0   \n2014-01-09  4.20  4.23  4.05   4.09       4.09  30667600                  0   \n\n            Buy_Sell_on_Open  Buy_Sell   Returns  \nDate                                              \n2014-01-03                 1         1  0.012658  \n2014-01-06                 1         1  0.032500  \n2014-01-07                 1         0  0.012106  \n2014-01-08                 0         0  0.000000  \n2014-01-09                 0         1 -0.021531  ",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n      <th>Increase_Decrease</th>\n      <th>Buy_Sell_on_Open</th>\n      <th>Buy_Sell</th>\n      <th>Returns</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2014-01-03</th>\n      <td>3.98</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>22887200</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.012658</td>\n    </tr>\n    <tr>\n      <th>2014-01-06</th>\n      <td>4.01</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.13</td>\n      <td>4.13</td>\n      <td>42398300</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.032500</td>\n    </tr>\n    <tr>\n      <th>2014-01-07</th>\n      <td>4.19</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>42932100</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0.012106</td>\n    </tr>\n    <tr>\n      <th>2014-01-08</th>\n      <td>4.23</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>30678700</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>2014-01-09</th>\n      <td>4.20</td>\n      <td>4.23</td>\n      <td>4.05</td>\n      <td>4.09</td>\n      <td>4.09</td>\n      <td>30667600</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1</td>\n      <td>-0.021531</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 4,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:25.409Z",
          "iopub.execute_input": "2022-05-28T21:33:25.414Z",
          "iopub.status.idle": "2022-05-28T21:33:25.424Z",
          "shell.execute_reply": "2022-05-28T21:33:25.534Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "dataset.tail()"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 5,
          "data": {
            "text/plain": "                 Open   High        Low      Close  Adj Close     Volume  \\\nDate                                                                       \n2018-08-20  19.790001  20.08  19.350000  19.980000  19.980000   62983200   \n2018-08-21  19.980000  20.42  19.860001  20.400000  20.400000   55629000   \n2018-08-22  20.280001  20.92  20.209999  20.900000  20.900000   62002700   \n2018-08-23  21.190001  22.32  21.139999  22.290001  22.290001  113444100   \n2018-08-24  22.910000  24.00  22.670000  23.980000  23.980000  164328200   \n\n            Increase_Decrease  Buy_Sell_on_Open  Buy_Sell   Returns  \nDate                                                                 \n2018-08-20                  0                 1         1  0.010622  \n2018-08-21                  1                 1         1  0.021021  \n2018-08-22                  1                 1         1  0.024510  \n2018-08-23                  1                 1         1  0.066507  \n2018-08-24                  0                 0         0  0.075819  ",
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Open</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Close</th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n      <th>Increase_Decrease</th>\n      <th>Buy_Sell_on_Open</th>\n      <th>Buy_Sell</th>\n      <th>Returns</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2018-08-20</th>\n      <td>19.790001</td>\n      <td>20.08</td>\n      <td>19.350000</td>\n      <td>19.980000</td>\n      <td>19.980000</td>\n      <td>62983200</td>\n      <td>0</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.010622</td>\n    </tr>\n    <tr>\n      <th>2018-08-21</th>\n      <td>19.980000</td>\n      <td>20.42</td>\n      <td>19.860001</td>\n      <td>20.400000</td>\n      <td>20.400000</td>\n      <td>55629000</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.021021</td>\n    </tr>\n    <tr>\n      <th>2018-08-22</th>\n      <td>20.280001</td>\n      <td>20.92</td>\n      <td>20.209999</td>\n      <td>20.900000</td>\n      <td>20.900000</td>\n      <td>62002700</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.024510</td>\n    </tr>\n    <tr>\n      <th>2018-08-23</th>\n      <td>21.190001</td>\n      <td>22.32</td>\n      <td>21.139999</td>\n      <td>22.290001</td>\n      <td>22.290001</td>\n      <td>113444100</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.066507</td>\n    </tr>\n    <tr>\n      <th>2018-08-24</th>\n      <td>22.910000</td>\n      <td>24.00</td>\n      <td>22.670000</td>\n      <td>23.980000</td>\n      <td>23.980000</td>\n      <td>164328200</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0.075819</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
          },
          "metadata": {}
        }
      ],
      "execution_count": 5,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:25.431Z",
          "iopub.execute_input": "2022-05-28T21:33:25.438Z",
          "iopub.status.idle": "2022-05-28T21:33:25.450Z",
          "shell.execute_reply": "2022-05-28T21:33:25.537Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "dataset.shape"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 6,
          "data": {
            "text/plain": "(1170, 10)"
          },
          "metadata": {}
        }
      ],
      "execution_count": 6,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:25.457Z",
          "iopub.execute_input": "2022-05-28T21:33:25.462Z",
          "iopub.status.idle": "2022-05-28T21:33:25.473Z",
          "shell.execute_reply": "2022-05-28T21:33:25.541Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "n = len(dataset.index)\n",
        "X = np.array(dataset['Open']).reshape(n,-1)\n",
        "y = np.array(dataset['Adj Close']).reshape(n,-1)"
      ],
      "outputs": [],
      "execution_count": 7,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:25.481Z",
          "iopub.execute_input": "2022-05-28T21:33:25.485Z",
          "iopub.status.idle": "2022-05-28T21:33:25.493Z",
          "shell.execute_reply": "2022-05-28T21:33:25.544Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.model_selection import train_test_split\n",
        "\n",
        "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25, random_state = 0)\n",
        "print ('Train set:', X_train.shape,  y_train.shape)\n",
        "print ('Test set:', X_test.shape,  y_test.shape)"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Train set: (877, 1) (877, 1)\n",
            "Test set: (293, 1) (293, 1)\n"
          ]
        }
      ],
      "execution_count": 8,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:25.500Z",
          "iopub.execute_input": "2022-05-28T21:33:25.505Z",
          "shell.execute_reply": "2022-05-28T21:33:26.362Z",
          "iopub.status.idle": "2022-05-28T21:33:26.291Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.gaussian_process import GaussianProcessRegressor\n",
        "from sklearn.gaussian_process.kernels import DotProduct, WhiteKernel"
      ],
      "outputs": [],
      "execution_count": 9,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:26.298Z",
          "iopub.execute_input": "2022-05-28T21:33:26.303Z",
          "iopub.status.idle": "2022-05-28T21:33:26.311Z",
          "shell.execute_reply": "2022-05-28T21:33:26.366Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "kernel = DotProduct() + WhiteKernel()"
      ],
      "outputs": [],
      "execution_count": 10,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:26.319Z",
          "iopub.execute_input": "2022-05-28T21:33:26.326Z",
          "iopub.status.idle": "2022-05-28T21:33:26.334Z",
          "shell.execute_reply": "2022-05-28T21:33:26.369Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "model = GaussianProcessRegressor(kernel=kernel, random_state=0).fit(X, y)"
      ],
      "outputs": [],
      "execution_count": 11,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:26.342Z",
          "iopub.execute_input": "2022-05-28T21:33:26.347Z",
          "iopub.status.idle": "2022-05-28T21:33:29.612Z",
          "shell.execute_reply": "2022-05-28T21:33:29.708Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "model.score(X, y)"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 12,
          "data": {
            "text/plain": "0.9976581584460951"
          },
          "metadata": {}
        }
      ],
      "execution_count": 12,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:29.624Z",
          "iopub.execute_input": "2022-05-28T21:33:29.630Z",
          "iopub.status.idle": "2022-05-28T21:33:29.641Z",
          "shell.execute_reply": "2022-05-28T21:33:29.713Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "model.predict(X[:2,:], return_std=True)"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 13,
          "data": {
            "text/plain": "(array([[3.98063636],\n        [4.01064136]]),\n array([0.23528769, 0.23528802]))"
          },
          "metadata": {}
        }
      ],
      "execution_count": 13,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:29.651Z",
          "iopub.execute_input": "2022-05-28T21:33:29.659Z",
          "iopub.status.idle": "2022-05-28T21:33:29.672Z",
          "shell.execute_reply": "2022-05-28T21:33:29.718Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "gau = GaussianProcessRegressor()\n",
        "gau.fit(X_train, y_train)"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 14,
          "data": {
            "text/plain": "GaussianProcessRegressor()"
          },
          "metadata": {}
        }
      ],
      "execution_count": 14,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:29.683Z",
          "iopub.execute_input": "2022-05-28T21:33:29.691Z",
          "iopub.status.idle": "2022-05-28T21:33:29.754Z",
          "shell.execute_reply": "2022-05-28T21:33:29.735Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "y_pred = gau.predict(X_test)"
      ],
      "outputs": [],
      "execution_count": 15,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:29.761Z",
          "iopub.execute_input": "2022-05-28T21:33:29.766Z",
          "iopub.status.idle": "2022-05-28T21:33:29.771Z",
          "shell.execute_reply": "2022-05-28T21:33:29.738Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.metrics import mean_squared_error\n",
        "print('The rmse of prediction is:', mean_squared_error(y_test, y_pred) ** 0.5)"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "The rmse of prediction is: 0.26724316896309286\n"
          ]
        }
      ],
      "execution_count": 16,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:29.777Z",
          "iopub.execute_input": "2022-05-28T21:33:29.782Z",
          "iopub.status.idle": "2022-05-28T21:33:29.791Z",
          "shell.execute_reply": "2022-05-28T21:33:29.843Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "gau.score(X_test, y_test)"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 17,
          "data": {
            "text/plain": "0.9969508560922568"
          },
          "metadata": {}
        }
      ],
      "execution_count": 17,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:29.798Z",
          "iopub.execute_input": "2022-05-28T21:33:29.804Z",
          "iopub.status.idle": "2022-05-28T21:33:29.813Z",
          "shell.execute_reply": "2022-05-28T21:33:29.847Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn import metrics\n",
        "print('MAE:', metrics.mean_absolute_error(y_test, y_pred))\n",
        "print('MSE:', metrics.mean_squared_error(y_test, y_pred))\n",
        "print('RMSE:', np.sqrt(metrics.mean_squared_error(y_test, y_pred)))"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "MAE: 0.16841633785684879\n",
            "MSE: 0.07141891135743621\n",
            "RMSE: 0.26724316896309286\n"
          ]
        }
      ],
      "execution_count": 18,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2022-05-28T21:33:29.820Z",
          "iopub.execute_input": "2022-05-28T21:33:29.824Z",
          "iopub.status.idle": "2022-05-28T21:33:29.833Z",
          "shell.execute_reply": "2022-05-28T21:33:29.850Z"
        }
      }
    }
  ],
  "metadata": {
    "kernel_info": {
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.6.13",
      "mimetype": "text/x-python",
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "pygments_lexer": "ipython3",
      "nbconvert_exporter": "python",
      "file_extension": ".py"
    },
    "kernelspec": {
      "argv": [
        "C:/Users/Tin Hang/Anaconda3\\python.exe",
        "-m",
        "ipykernel_launcher",
        "-f",
        "{connection_file}"
      ],
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "nteract": {
      "version": "0.28.0"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}